package thinkinginjava.concurrency;

import java.util.concurrent.BlockingQueue;

public class LiftoffRunner implements Runnable{
	private BlockingQueue<LiftoffRunner> liftoffs;
	
	public LiftoffRunner(BlockingQueue<LiftoffRunner> rockets) {
		this.liftoffs = rockets;
	}
	
	
	@Override
	public void run() {
		try {
			while(true) {
				if(!Thread.interrupted()) {
					LiftoffRunner rocket = liftoffs.take();
					rocket.run();
				}
			}
			
		} catch (InterruptedException e) {
			System.out.println("Waking from take()");
		}
		
	}

}
